#ifndef CORRELATIONMATRIX_H
#define CORRELATIONMATRIX_H
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <anatomicallink.h>
#include <sstream>
#include <stdlib.h>
#include <QObject>
#include <QPoint>
#include <QVector>
#include <matio.h>

class CorrelationMatrix : public QObject
{
	typedef std::vector<double> DoubleVector;

    Q_OBJECT

public:
   CorrelationMatrix();
   CorrelationMatrix(const CorrelationMatrix& m);               // Copy constructor
   CorrelationMatrix& operator= (const CorrelationMatrix& m);   // Assignment operator
   ~CorrelationMatrix();                                      // Destructor

   void addRow(DoubleVector vector);

   double at(unsigned row, unsigned col) const;
   void set(unsigned row, unsigned col, double newval);
   //QPoint getIndex(AnatomicalLink *link);

   unsigned height() const;
   unsigned width() const;

   double minValue();
   double maxValue();

   void print();

   static QVector<CorrelationMatrix*> createListFromFile(std::string filepath);
   static CorrelationMatrix* createFromFile(std::string filepath);

   void loadFromCSVFile(std::string filepath);
   void loadFromMATFile(std::string filepath);

private:
	std::vector<DoubleVector> *rows_;
   int getListIndexFromMatrixPosition(int row, int col, int numRows, int numCols);
   void addLastRow();

signals:
   void changed(int row, int col);
};

#endif // CORRELATIONMATRIX_H
